Fix uncleaned vif backend devices when frontend does not finish
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Dec 2005 13:55:55 +0000 (14:55 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 28 Dec 2005 13:55:55 +0000 (14:55 +0100)
initialization properly.

Signed-off-by: Murillo F. Bernardes <mfb@br.ibm.com>
linux-2.6-xen-sparse/drivers/xen/netback/interface.c

index 9e336db31c9a0aac4737c852f42ccff1014caa6b..c2641d99c9230429eac9759c48af57e78b18ab33 100644 (file)
@@ -247,13 +247,9 @@ static void free_netif_callback(void *arg)
 {
        netif_t *netif = (netif_t *)arg;
 
-       /* Already disconnected? */
-       if (!netif->irq)
-               return;
-
-       unbind_from_irqhandler(netif->irq, netif);
-       netif->irq = 0;
-
+       if (netif->irq)
+               unbind_from_irqhandler(netif->irq, netif);
+       
        unregister_netdev(netif->dev);
 
        if (netif->tx.sring) {
@@ -290,10 +286,10 @@ void netif_creditlimit(netif_t *netif)
 #endif
 }
 
-int netif_disconnect(netif_t *netif)
+void netif_disconnect(netif_t *netif)
 {
-
-       if (netif->status == CONNECTED) {
+       switch (netif->status) {
+       case CONNECTED:
                rtnl_lock();
                netif->status = DISCONNECTING;
                wmb();
@@ -301,10 +297,14 @@ int netif_disconnect(netif_t *netif)
                        __netif_down(netif);
                rtnl_unlock();
                netif_put(netif);
-               return 0; /* Caller should not send response message. */
+               break;
+       case DISCONNECTED:
+               BUG_ON(atomic_read(&netif->refcnt) != 0);
+               free_netif(netif);
+               break;
+       default:
+               BUG();
        }
-
-       return 1;
 }
 
 /*